package com.fms.controller;

import com.fms.dto.SignPhotoDto;
import com.fms.result.ResultData;
import com.fms.service.PhotoInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

@RestController
@CrossOrigin
@RequestMapping("/photo")
@RequiredArgsConstructor
public class PhotoInfoController {
    private final PhotoInfoService photoInfoService;

    @PostMapping("/deletePhoto")
    public ResultData deleteContractPhoto(@RequestBody String contractPhotoUrl) throws UnsupportedEncodingException {
        System.out.println(contractPhotoUrl);
        ResultData resultData = photoInfoService.deleteContractPhoto(contractPhotoUrl);
        return resultData;
    }

    @PostMapping("/addSignPhoto")
    public ResultData addSignPhoto(@RequestBody SignPhotoDto signPhotoDto) throws IOException {
        System.out.println(signPhotoDto);
        ResultData resultData = photoInfoService.addSignPhoto(signPhotoDto);
        return resultData;
    }
}
